$OpenBSD: patch-CMakeLists_txt,v 1.18 2017/03/21 19:48:01 dcoppa Exp $

These auto-generated (db2man.xsl) manpages contain a mixture of ISO
latin-1 characters and numerical HTML entities that neither mandoc
nor groff can fully understand: do not install them.

Fix usage of -export-dynamic

--- CMakeLists.txt.orig	Sat Mar 18 10:49:46 2017
+++ CMakeLists.txt	Tue Mar 21 18:07:44 2017
@@ -81,7 +81,6 @@ set(AWE_MAN_SRCS
     ${SOURCE_DIR}/manpages/awesome.1.txt
     ${SOURCE_DIR}/manpages/awesome-client.1.txt
     ${SOURCE_DIR}/manpages/awesomerc.5.txt)
-set(AWE_MAN_LANGS it es fr de ru)
 
 # Don't strip RPATH if compiling on Solaris
 if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
@@ -95,12 +94,11 @@ add_executable(${PROJECT_AWE_NAME}
 
 # CFLAGS
 set(AWESOME_C_FLAGS
-    -O1 -std=gnu99 -ggdb3 -fno-strict-aliasing -Wall -Wextra
-    -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings
-    -Wsign-compare -Wunused -Wno-unused-parameter -Wuninitialized -Winit-self
-    -Wpointer-arith -Wformat-nonliteral
-    -Wno-format-zero-length -Wmissing-format-attribute -Wmissing-prototypes
-    -Wstrict-prototypes
+    -std=gnu99 -fgnu89-inline -fno-strict-aliasing
+    -Wchar-subscripts -Wcast-align -Wwrite-strings -Wsign-compare
+    -Wunused -Wno-unused-parameter -Wuninitialized -Wpointer-arith
+    -Wno-format-zero-length -Wmissing-format-attribute
+    -Wmissing-prototypes -Wstrict-prototypes
     CACHE STRING "CFLAGS used to compile ${PROJECT_AWE_NAME}")
 mark_as_advanced(AWESOME_C_FLAGS)
 target_compile_options(${PROJECT_AWE_NAME} PRIVATE ${AWESOME_C_FLAGS})
@@ -108,23 +106,11 @@ target_compile_options(${PROJECT_AWE_NAME} PRIVATE ${A
 # Make sure awesomerc.lua is generated
 add_dependencies(${PROJECT_AWE_NAME} generate_awesomerc)
 
-# Linux w/ GCC requires -rdynamic to get backtrace to fully work.
-#
-# For "historical reasons", CMake adds the option to the linker flags
-# unnoticeably for Linux w/ GCC through its modules Linux-GNU.cmake
-# and Linux-GNU-C.cmake.  Our build system has counted on that.  But
-# just in case CMake should do away with the convention suddenly...
-if(DEFINED CMAKE_SHARED_LIBRARY_LINK_C_FLAGS AND
-        NOT CMAKE_SHARED_LIBRARY_LINK_C_FLAGS MATCHES "-rdynamic")
-    target_link_libraries(${PROJECT_AWE_NAME}
-        $<$<AND:$<PLATFORM_ID:Linux>,$<C_COMPILER_ID:GNU>>:-rdynamic>)
-endif()
-
-# FreeBSD requires dynamic linking
-if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
+# FreeBSD and OpenBSD require dynamic linking
+if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
     set_target_properties(${PROJECT_AWE_NAME}
         PROPERTIES
-        LINK_FLAGS -export-dynamic)
+        LINK_FLAGS -Wl,--export-dynamic)
 endif()
 
 target_link_libraries(${PROJECT_AWE_NAME}
@@ -132,10 +118,6 @@ target_link_libraries(${PROJECT_AWE_NAME}
     ${AWESOME_REQUIRED_LDFLAGS}
     ${AWESOME_OPTIONAL_LDFLAGS})
 
-# check for lgi and the needed gobject introspection files
-add_custom_target(lgi-check ALL
-    COMMAND ${SOURCE_DIR}/build-utils/lgi-check.sh)
-
 # {{{ Generated sources
 # atoms
 file(MAKE_DIRECTORY ${BUILD_DIR}/common)
@@ -186,68 +168,45 @@ if(GENERATE_MANPAGES)
     if(NOT BUILD_DIR STREQUAL SOURCE_DIR)
         file(MAKE_DIRECTORY ${BUILD_DIR}/manpages)
     endif()
+    foreach(txtfile ${AWE_MAN_SRCS})
+        string(REGEX REPLACE ".txt\$" ".xml" xmlfile ${txtfile})
+        string(REPLACE ${SOURCE_DIR}
+                       ${BUILD_DIR} xmlfile ${xmlfile})
+        string(REGEX REPLACE ".xml\$" ".gz" gzfile ${xmlfile})
+        string(REGEX REPLACE ".gz\$" "" manfile ${gzfile})
 
-    # add the default translation to the list of languages
-    set(AWE_MAN_LANGS default ${AWE_MAN_LANGS})
+        add_custom_command(
+            COMMAND ${ASCIIDOC_EXECUTABLE} -d manpage -b docbook -o ${xmlfile} - < ${txtfile}
+            WORKING_DIRECTORY ${BUILD_DIR}/manpages
+            OUTPUT  ${xmlfile}
+            DEPENDS ${txtfile}
+            VERBATIM)
+        add_custom_command(
+            COMMAND ${XMLTO_EXECUTABLE} --skip-validation man ${xmlfile}
+            OUTPUT  ${manfile}
+            WORKING_DIRECTORY ${BUILD_DIR}/manpages
+            DEPENDS ${xmlfile})
 
-    foreach(lang ${AWE_MAN_LANGS})
-
-        foreach(txtfile ${AWE_MAN_SRCS})
-            # figure the base name of the file (ie "awesome.1")
-            GET_FILENAME_COMPONENT(tmpname ${txtfile} NAME)
-            string(REGEX REPLACE ".txt\$" "" basename ${tmpname})
-
-            # figure the relative path of the file
-            GET_FILENAME_COMPONENT(tmppath ${txtfile} PATH)
-            string(REPLACE ${SOURCE_DIR}/ "" relpath ${tmppath})
-
-            # figure the manpage section to install to from filename
-            string(REGEX REPLACE "^.*\\.([0-9])$" "\\1" section ${basename})
-
-            # construct the language specific versions of the basename and path
-            if (lang STREQUAL default)
-                set(basename2 ${basename})
-                set(relpath2 ${relpath}/man${section})
-            else()
-                set(basename2 ${basename}.${lang})
-                set(relpath2 ${relpath}/${lang}/man${section})
-            endif()
-
-            # create the build directory (if it does not exist)
-            file(MAKE_DIRECTORY ${BUILD_DIR}/${relpath2})
-
-            # set the final filenames
-            set(txtfile ${SOURCE_DIR}/${relpath}/${basename2}.txt)
-            set(xmlfile ${BUILD_DIR}/${relpath2}/${basename}.xml)
-            set(gzfile  ${BUILD_DIR}/${relpath2}/${basename}.gz)
-            set(manfile ${BUILD_DIR}/${relpath2}/${basename})
-
+        if(COMPRESS_MANPAGES)
             add_custom_command(
-                COMMAND ${ASCIIDOC_EXECUTABLE} -d manpage -b docbook -o ${xmlfile} - < ${txtfile}
-                WORKING_DIRECTORY ${BUILD_DIR}/${relpath2}
-                OUTPUT  ${xmlfile}
-                DEPENDS ${txtfile}
+                COMMAND ${GZIP_EXECUTABLE} < ${manfile} > ${gzfile}
+                OUTPUT  ${gzfile}
+                WORKING_DIRECTORY ${BUILD_DIR}/manpages
+                DEPENDS ${manfile}
                 VERBATIM)
-            add_custom_command(
-                COMMAND ${XMLTO_EXECUTABLE} man ${xmlfile}
-                OUTPUT  ${manfile}
-                WORKING_DIRECTORY ${BUILD_DIR}/${relpath2}
-                DEPENDS ${xmlfile})
 
-            if(COMPRESS_MANPAGES)
-                add_custom_command(
-                    COMMAND ${GZIP_EXECUTABLE} < ${manfile} > ${gzfile}
-                    OUTPUT  ${gzfile}
-                    WORKING_DIRECTORY ${BUILD_DIR}/${relpath2}
-                    DEPENDS ${manfile}
-                    VERBATIM)
+            set(MAN_FILES ${MAN_FILES} ${gzfile})
+        else()
+            set(MAN_FILES ${MAN_FILES} ${manfile})
+        endif()
 
-                set(MAN_FILES ${MAN_FILES} ${gzfile})
-            else()
-                set(MAN_FILES ${MAN_FILES} ${manfile})
-            endif()
-        endforeach()
-
+        # figure out in what section to install to from filename
+        string(REGEX REPLACE "^.*\\.([0-9])\\.gz\$" "\\1" section ${gzfile})
+        if(COMPRESS_MANPAGES)
+            set(AWE_MAN${section}_FILES ${AWE_MAN${section}_FILES} ${gzfile})
+        else()
+            set(AWE_MAN${section}_FILES ${AWE_MAN${section}_FILES} ${manfile})
+        endif()
     endforeach()
 
     add_custom_target(man ALL DEPENDS ${MAN_FILES})
@@ -354,13 +313,8 @@ install(DIRECTORY ${BUILD_DIR}/lib DESTINATION ${AWESO
 install(FILES ${BUILD_DIR}/awesomerc.lua DESTINATION ${AWESOME_SYSCONFDIR}
         RENAME rc.lua)
 if(GENERATE_MANPAGES)
-    if(COMPRESS_MANPAGES)
-        set(regex "\\.(xml|txt|[0-9])$")
-    else()
-        set(regex "\\.(xml|txt|gz)$")
-    endif()
-    install(DIRECTORY ${BUILD_DIR}/${relpath}/ DESTINATION ${AWESOME_MAN_PATH}
-            REGEX ${regex} EXCLUDE )
+    install(FILES ${AWE_MAN1_FILES} DESTINATION ${AWESOME_MAN_PATH}/man1)
+    install(FILES ${AWE_MAN5_FILES} DESTINATION ${AWESOME_MAN_PATH}/man5)
 endif()
 install(DIRECTORY ${AWE_ICON_DIR} DESTINATION ${AWESOME_DATA_PATH})
 install(DIRECTORY ${SOURCE_DIR}/themes DESTINATION ${AWESOME_DATA_PATH}
@@ -374,6 +328,7 @@ if(GENERATE_DOC)
 endif()
 # }}}
 
+#[[
 # {{{ Tests
 add_custom_target(check-integration
     sh -c "CMAKE_BINARY_DIR='${CMAKE_BINARY_DIR}' ${CMAKE_SOURCE_DIR}/tests/run.sh"
@@ -422,5 +377,6 @@ add_custom_target(check DEPENDS ${CHECK_TARGETS} check
 # }}}
 
 INCLUDE(${CMAKE_SOURCE_DIR}/Packaging.cmake)
+]]
 
 # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80:foldmethod=marker
